#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int a[55], b[55], c[55];
	int vis[55] = { 0 }, flag[55] = { 0 };
	int m, n, top=0;
	scanf("%d", &m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d", &a[i]);
		vis[a[i]] = 1;
	}
	scanf("%d", &n);
	for (int j = 0; j < n; j++)
	{
		scanf("%d", &b[j]);
		if (vis[b[j]] == 1 && flag[b[j]] == 0)
		{
			c[top++] = b[j];
			flag[b[j]] = 1;
		}
	}
	for (int i = 0; i < top - 1; i++) printf("%d ", c[i]);
	printf("%d", c[top - 1]);
	return 0;
}